﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace NFit.WordML
{
    public enum ElementType
    {
        None = 0,
        Specification = 1,
        Fixture = 2
    }

    public class WordFileMapElement
    {
        [XmlAttribute]
        public string StyleName { get; set; }

        [XmlAttribute]
        public string Name { get; set; }

        [XmlAttribute]
        public ElementType EltType { get; set; }

        [XmlAttribute]
        public string ClassName { get; set; }

        public List<WordFileMapElement> Childs { get; set; }

        private void InitChilds()
        {
            if (Childs == null)
            {
                Childs = new List<WordFileMapElement>();
            }
        }

        public WordFileMapElement AddChild(WordFileMapElement elt)
        {
            InitChilds();
            Childs.Add(elt);

            return elt;
        }

        public WordFileMapElement AddChild(string stylename)
        {
            var elt = new WordFileMapElement {StyleName = stylename};
            AddChild(elt);

            return elt;
        }

        public WordFileMapElement AddChild(string stylename, string name)
        {
            var elt = new WordFileMapElement { StyleName = stylename, Name = name };
            AddChild(elt);

            return elt;
        }

        public WordFileMapElement AddChild(string stylename, string name, ElementType eltType)
        {
            var elt = new WordFileMapElement { StyleName = stylename, Name = name, EltType = eltType };
            AddChild(elt);

            return elt;
        }

        public WordFileMapElement AddChild(string stylename, string name, ElementType eltType, string classname)
        {
            var elt = new WordFileMapElement { StyleName = stylename, Name = name, EltType = eltType, ClassName = classname};
            AddChild(elt);

            return elt;
        }
    }
}
